// 解构表达式
// 1、基于数组的解构表达式
let [tiger, pig, dog] = ["tiger000", "pig000", "dog000"];
console.log("tiger = " + tiger)
console.log("pig = " + pig)
console.log("dog = " + dog)

console.log("------------------------------------------")

// 2、基于对象的解构表达式
let {apple, banana, orange} = {
    apple: "apple~~~",
    banana: "banana~~~",
    orange: "orange~~~"
};
console.log(`apple = ${apple}`)
console.log(`banana = ${banana}`)
console.log(`orange = ${orange}`)

console.log("------------------------------------------")

// 3、在解构表达式中声明别名
let {stuId:studentId, stuName:studentName, stuAge:studentAge} = {
    stuId:555,
    stuName:"tom555",
    stuAge:111
};
console.log(`studentId = ${studentId}`)
console.log(`studentName = ${studentName}`)
console.log(`studentAge = ${studentAge}`)

console.log("------------------------------------------")

// 4、应用场景
// [1]声明函数，函数返回对象
function getEmp() {
    return {
        empId: 666,
        empName: "Jerry2025",
        empSalary: 666.66
    };
}

// [2]调用函数并声明变量接收函数返回值
let emp = getEmp();

// [3]打印
console.log(emp)

console.log("------------------------------------------")

// [4]测试解构表达式
// 需求：对于函数返回值只需要其中的一个属性
let {empName} = getEmp();

console.log(`empName = ${empName}`)